package com.xbongbong.formula.qlexpress.operator.math;

import com.ql.util.express.Operator;
import com.ql.util.express.OperatorOfNumber;

/**
 * @author: wufeng
 * @date: 2018/7/4 17:18
 * @desrcption: 返回数字乘幂的结果。
 */
public class OperatorPower extends Operator {

    public OperatorPower(String name){
        this.name = name;
    }

    public OperatorPower(String aliasName, String aName, String errorInfo){
        this.aliasName = aliasName;
        this.name = aName;
        this.errorInfo = errorInfo;
    }


    @Override
    public Object executeInner(Object[] list) throws Exception {
        Object sum = list[0];
        int length = ((Number) list[1]).intValue();
        for(int i=0; i < length-1; i++){
            sum =  OperatorOfNumber.multiply(list[0], sum,this.isPrecise);
        }
      return sum;
    }

}
